home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1998 November / Freeware November 1998.img / dist / fw_emacs.idb / usr / freeware / info / forms.z / forms (.txt)
GNU Info File  |  1998-10-27  |  33KB  |  681 lines

  1. This is Info file ../info/forms, produced by Makeinfo-1.64 from the
  2. input file forms.texi.
  3.    This file documents Forms mode, a form-editing major mode for GNU
  4. Emacs.
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8. File: forms,  Node: Top,  Next: Forms Example,  Up: (dir)
  9. Forms Mode
  10. **********
  11.    Forms mode is an Emacs major mode for working with simple textual
  12. data bases in a forms-oriented manner.  In Forms mode, the information
  13. in these files is presented in an Emacs window in a user-defined format,
  14. one record at a time.  The user can view records or modify their
  15. contents.
  16.    Forms mode is not a simple major mode, but requires two files to do
  17. its job: a control file and a data file.  The data file holds the
  18. actual data to be presented.  The control file describes how to present
  19. * Menu:
  20. * Forms Example::               An example: editing the password data base.
  21. * Entering and Exiting Forms Mode::
  22.                                 How to visit a file in Forms mode.
  23. * Forms Commands::              Special commands to use while in Forms mode.
  24. * Data File Format::            How to format the data file.
  25. * Control File Format::         How to control forms mode.
  26. * Format Description::          How to define the forms layout.
  27. * Modifying Forms Contents::    How to modify.
  28. * Miscellaneous::               Forms mode messages and other remarks.
  29. * Error Messages::              List of error messages forms mode can produce.
  30. * Long Example::                A more complex control file example.
  31. * Credits::                     Thanks everyone.
  32. * Index::                       Index to this manual.
  33. File: forms,  Node: Forms Example,  Next: Entering and Exiting Forms Mode,  Prev: Top,  Up: Top
  34. Forms Example
  35. *************
  36.    Let's illustrate Forms mode with an example.  Suppose you are
  37. looking at the `/etc/passwd' file, and the screen looks like this:
  38.      ====== /etc/passwd ======
  39.      
  40.      User : root   Uid: 0   Gid: 1
  41.      
  42.      Name : Super User
  43.      
  44.      Home : /
  45.      
  46.      Shell: /bin/sh
  47.    As you can see, the familiar fields from the entry for the super user
  48. are all there, but instead of being colon-separated on one single line,
  49. they make up a forms.
  50.    The contents of the forms consist of the contents of the fields of
  51. the record (e.g. `root', `0', `1', `Super User') interspersed with
  52. normal text (e.g `User : ', `Uid: ').
  53.    If you modify the contents of the fields, Forms mode will analyze
  54. your changes and update the file appropriately.  You cannot modify the
  55. interspersed explanatory text (unless you go to some trouble about it),
  56. because that is marked read-only (*note Text Properties: (elisp)Text
  57. Properties.).
  58.    The Forms mode control file specifies the relationship between the
  59. format of `/etc/passwd' and what appears on the screen in Forms mode.
  60. *Note Control File Format::.
  61. File: forms,  Node: Entering and Exiting Forms Mode,  Next: Forms Commands,  Prev: Forms Example,  Up: Top
  62. Entering and Exiting Forms Mode
  63. *******************************
  64. `M-x forms-find-file RET CONTROL-FILE RET'
  65.      Visit a database using Forms mode.  Specify the name of the
  66.      *control file*, not the data file!
  67. `M-x forms-find-file-other-window RET CONTROL-FILE RET'
  68.      Similar, but displays the file in another window.
  69.    The command `forms-find-file' evaluates the file CONTROL-FILE, and
  70. also visits it in Forms mode.  What you see in its buffer is not the
  71. contents of this file, but rather a single record of the corresponding
  72. data file that is visited in its own buffer.  So there are two buffers
  73. involved in Forms mode: the "forms buffer" that is initially used to
  74. visit the control file and that shows the records being browsed, and
  75. the "data buffer" that holds the data file being visited.  The latter
  76. buffer is normally not visible.
  77.    Initially, the first record is displayed in the forms buffer.  The
  78. mode line displays the major mode name `Forms', followed by the minor
  79. mode `View' if the data base is read-only.  The number of the current
  80. record (N) and the total number of records in the file(T) are shown in
  81. the mode line as `N/T'.  For example:
  82.      --%%-Emacs: passwd-demo          (Forms View 1/54)----All-------
  83.    If the buffer is not read-only, you may change the buffer to modify
  84. the fields in the record.  When you move to a different record, the
  85. contents of the buffer are parsed using the specifications in
  86. `forms-format-list', and the data file is updated.  If the record has
  87. fields that aren't included in the display, they are not changed.
  88.    Entering Forms mode runs the normal hook `forms-mode-hooks' to
  89. perform user-defined customization.
  90.    To save any modified data, you can use `C-x C-s'
  91. (`forms-save-buffer').  This does not save the forms buffer (which would
  92. be rather useless), but instead saves the buffer visiting the data file.
  93.    To terminate Forms mode, you can use `C-x C-s' (`forms-save-buffer')
  94. and then kill the forms buffer.  However, the data buffer will still
  95. remain.  If this is not desired, you have to kill this buffer too.
  96. File: forms,  Node: Forms Commands,  Next: Data File Format,  Prev: Entering and Exiting Forms Mode,  Up: Top
  97. Forms Commands
  98. **************
  99.    The commands of Forms mode belong to the `C-c' prefix, with one
  100. exception: TAB, which moves to the next field.  Forms mode uses
  101. different key maps for normal mode and read-only mode.  In read-only
  102. Forms mode, you can access most of the commands without the `C-c'
  103. prefix, but you must type ordinary letters instead of control
  104. characters; for example, type `n' instead of `C-c C-n'.
  105.    If your Emacs has been built with X-toolkit support, Forms mode will
  106. provide its own menu with a number of Forms mode commands.
  107. `C-c C-n'
  108.      Show the next record (`forms-next-record').  With a numeric
  109.      argument N, show the Nth next record.
  110. `C-c C-p'
  111.      Show the previous record (`forms-prev-record').  With a numeric
  112.      argument N, show the Nth previous record.
  113. `C-c C-l'
  114.      Jump to a record by number (`forms-jump-record').   Specify the
  115.      record number with a numeric argument.
  116. `C-c <'
  117.      Jump to the first record (`forms-first-record').
  118. `C-c >'
  119.      Jump to the last record (`forms-last-record').  This command also
  120.      recalculates the number of records in the data file.
  121. `TAB'
  122. `C-c TAB'
  123.      Jump to the next field in the current record (`forms-next-field').
  124.      With a numeric argument N, jump forward N fields.  If this command
  125.      would move past the last field, it wraps around to the first field.
  126. `C-c C-q'
  127.      Toggles read-only mode (`forms-toggle-read-only').  In read-only
  128.      Forms mode, you cannot edit the fields; most Forms mode commands
  129.      can be accessed without the prefix `C-c' if you use the normal
  130.      letter instead (for example, type `n' instead of `C-c C-n').  In
  131.      edit mode, you can edit the fields and thus change the contents of
  132.      the data base; you must begin Forms mode commands with `C-c'.
  133.      Switching to edit mode is allowed only if you have write access to
  134.      the data file.
  135. `C-c C-o'
  136.      Create a new record and insert it before the current record
  137.      (`forms-insert-record').  It starts out with empty (or default)
  138.      contents for its fields; you can then edit the fields.  With a
  139.      numeric argument, the new record is created *after* the current
  140.      one.  See also `forms-modified-record-filter' in *Note Modifying
  141.      Forms Contents::.
  142. `C-c C-k'
  143.      Delete the current record (`forms-delete-record').  You are
  144.      prompted for confirmation before the record is deleted unless a
  145.      numeric argument has been provided.
  146. `C-c C-s REGEXP RET'
  147.      Search forward for REGEXP in all records following this one
  148.      (`forms-search-forward').  If found, this record is shown.  If you
  149.      give an empty argument, the previous regexp is used again.
  150. `C-c C-r REGEXP RET'
  151.      Search backward for REGEXP in all records following this one
  152.      (`forms-search-backward').  If found, this record is shown.  If
  153.      you give an empty argument, the previous regexp is used again.
  154. `M-x forms-prev-field'
  155.      Similar to `forms-next-field' but moves backwards.
  156. `M-x forms-save-buffer'
  157. `C-x C-s'
  158.      Forms mode replacement for `save-buffer'. When executed in the
  159.      forms buffer it will save the contents of the (modified) data
  160.      buffer instead. In Forms mode this function will be bound to `C-x
  161.      C-s'.
  162. `M-x forms-print'
  163.      This command can be used to make a formatted print of the contents
  164.      of the data file.
  165.    In addition the command `M-x revert-buffer' is useful in Forms mode
  166. just as in other modes.
  167.    The following function key definitions are set up in Forms mode
  168. (whether read-only or not):
  169. `next'
  170.      forms-next-record
  171. `prior'
  172.      forms-prev-record
  173. `begin'
  174.      forms-first-record
  175. `end'
  176.      forms-last-record
  177. `S-Tab'
  178.      forms-prev-field
  179. File: forms,  Node: Data File Format,  Next: Control File Format,  Prev: Forms Commands,  Up: Top
  180. Data File Format
  181. ****************
  182.    Files for use with Forms mode are very simple--each "record"
  183. (usually one line) forms the contents of one form.  Each record consists
  184. of a number of "fields", which are separated by the value of the string
  185. `forms-field-sep', which is `"\t"' (a Tab) by default.
  186.    If the format of the data file is not suitable enough you can define
  187. the filter functions `forms-read-file-filter' and
  188. `forms-write-file-filter'. `forms-read-file-filter' is called when the
  189. data file is read from disk into the data buffer. It operates on the
  190. data buffer, ignoring read-only protections. When the data file is
  191. saved to disk `forms-write-file-filter' is called to cancel the effects
  192. of `forms-read-file-filter'. After being saved,
  193. `forms-read-file-filter' is called again to prepare the data buffer for
  194. further processing.
  195.    Fields may contain text which shows up in the forms in multiple
  196. lines.  These lines are separated in the field using a "pseudo-newline"
  197. character which is defined by the value of the string
  198. `forms-multi-line'.  Its default value is `"\^k"' (a Control-K
  199. character).  If it is set to `nil', multiple line fields are prohibited.
  200.    If the data file does not exist, it is automatically created.
  201. File: forms,  Node: Control File Format,  Next: Format Description,  Prev: Data File Format,  Up: Top
  202. Control File Format
  203. *******************
  204.    The Forms mode "control file" serves two purposes.  First, it names
  205. the data file to use, and defines its format and properties.  Second,
  206. the Emacs buffer it occupies is used by Forms mode to display the forms.
  207.    The contents of the control file are evaluated as a Lisp program.  It
  208. should set the following Lisp variables to suitable values:
  209. `forms-file'
  210.      This variable specifies the name of the data file.  Example:
  211.           (setq forms-file "my/data-file")
  212.      If the control file doesn't set `forms-file', Forms mode reports
  213.      an error.
  214. `forms-format-list'
  215.      This variable describes the way the fields of the record are
  216.      formatted on the screen.  For details, see *Note Format
  217.      Description::.
  218. `forms-number-of-fields'
  219.      This variable holds the number of fields in each record of the data
  220.      file.  Example:
  221.           (setq forms-number-of-fields 10)
  222.    If the control file does not set `forms-format-list' a default
  223. format is used.  In this situation, Forms mode will deduce the number of
  224. fields from the data file providing this file exists and
  225. `forms-number-of-records' has not been set in the control file.
  226.    The control file can optionally set the following additional Forms
  227. mode variables.  Most of them have default values that are good for most
  228. applications.
  229. `forms-field-sep'
  230.      This variable may be used to designate the string which separates
  231.      the fields in the records of the data file.  If not set, it
  232.      defaults to the string `"\t"' (a Tab character).  Example:
  233.           (setq forms-field-sep "\t")
  234. `forms-read-only'
  235.      If the value is non-`nil', the data file is treated read-only.
  236.      (Forms mode also treats the data file as read-only if you don't
  237.      have access to write it.)  Example:
  238.           (set forms-read-only t)
  239. `forms-multi-line'
  240.      This variable specifies the "pseudo newline" separator that allows
  241.      multi-line fields.  This separator goes between the "lines" within
  242.      a field--thus, the field doesn't really contain multiple lines,
  243.      but it appears that way when displayed in Forms mode.  If the
  244.      value is `nil', multi-line text fields are prohibited.  The pseudo
  245.      newline must not be a character contained in `forms-field-sep'.
  246.      The default value is `"\^k"', the character Control-K.  Example:
  247.           (setq forms-multi-line "\^k")
  248. `forms-read-file-filter'
  249.      This variable holds the name of a function to be called after the
  250.      data file has been read in. This can be used to transform the
  251.      contents of the data file into a format more suitable for forms
  252.      processing.  If it is `nil', no function is called.
  253. `forms-write-file-filter'
  254.      This variable holds the name of a function to be called before
  255.      writing out the contents of the data file.  This can be used to
  256.      undo the effects of `forms-read-file-filter'.  If it is `nil', no
  257.      function is called.
  258. `forms-new-record-filter'
  259.      This variable holds a function to be called whenever a new record
  260.      is created to supply default values for fields.  If it is `nil',
  261.      no function is called.  *Note Modifying Forms Contents::, for
  262.      details.
  263. `forms-modified-record-filter'
  264.      This variable holds a function to be called whenever a record is
  265.      modified, just before updating the Forms data file.  If it is
  266.      `nil', no function is called.  *Note Modifying Forms Contents::,
  267.      for details.
  268. `forms-insert-after'
  269.      If this variable is not `nil', new records are created *after* the
  270.      current record. Also, upon visiting a file, the initial position
  271.      will be at the last record instead of the first one.
  272. `forms-check-number-of-fields'
  273.      Normally each record is checked to contain the correct number of
  274.      fields.  Under certain circumstances, this can be undesirable.  If
  275.      this variable is set to `nil', these checks will be bypassed.
  276. File: forms,  Node: Format Description,  Next: Modifying Forms Contents,  Prev: Control File Format,  Up: Top
  277. The Format Description
  278. **********************
  279.    The variable `forms-format-list' specifies the format of the data in
  280. the data file, and how to convert the data for display in Forms mode.
  281. Its value must be a list of Forms mode "formatting elements", each of
  282. which can be a string, a number, a Lisp list, or a Lisp symbol that
  283. evaluates to one of those.  The formatting elements are processed in the
  284. order they appear in the list.
  285. STRING
  286.      A string formatting element is inserted in the forms "as is," as
  287.      text that the user cannot alter.
  288. NUMBER
  289.      A number element selects a field of the record.  The contents of
  290.      this field are inserted in the display at this point.  Field
  291.      numbers count starting from 1 (one).
  292.      A formatting element that is a list specifies a function call.
  293.      This function is called every time a record is displayed, and its
  294.      result, which must be a string, is inserted in the display text.
  295.      The function should do nothing but returning a string.
  296.      The function you call can access the fields of the record as a
  297.      list in the variable `forms-fields'.
  298. SYMBOL
  299.      A symbol used as a formatting element should evaluate to a string,
  300.      number, or list; the value is interpreted as a formatting element,
  301.      as described above.
  302.    If a record does not contain the number of fields as specified in
  303. `forms-number-of-fields', a warning message will be printed.  Excess
  304. fields are ignored, missing fields are set to empty.
  305.    The control file which displays `/etc/passwd' file as demonstrated
  306. in the beginning of this manual might look as follows:
  307.      ;; This demo visits `/etc/passwd'.
  308.      
  309.      (setq forms-file "/etc/passwd")
  310.      (setq forms-number-of-fields 7)
  311.      (setq forms-read-only t)                 ; to make sure
  312.      (setq forms-field-sep ":")
  313.      ;; Don't allow multi-line fields.
  314.      (setq forms-multi-line nil)
  315.      
  316.      (setq forms-format-list
  317.            (list
  318.             "====== /etc/passwd ======\n\n"
  319.             "User : "    1
  320.             "   Uid: "   3
  321.             "   Gid: "   4
  322.             "\n\n"
  323.             "Name : "    5
  324.             "\n\n"
  325.             "Home : "    6
  326.             "\n\n"
  327.             "Shell: "    7
  328.             "\n"))
  329.    When you construct the value of  `forms-format-list', you should
  330. usually either quote the whole value, like this,
  331.      (setq forms-format-list
  332.           '(
  333.             "====== " forms-file " ======\n\n"
  334.             "User : "    1
  335.             (make-string 20 ?-)
  336.             ...
  337.            ))
  338. or quote the elements which are lists, like this:
  339.      (setq forms-format-list
  340.            (list
  341.             "====== " forms-file " ======\n\n"
  342.             "User : "    1
  343.             '(make-string 20 ?-)
  344.             ...
  345.            ))
  346.    Forms mode validates the contents of `forms-format-list' when you
  347. visit a database.  If there are errors, processing is aborted with an
  348. error message which includes a descriptive text.  *Note Error
  349. Messages::, for a detailed list of error messages.
  350.    If no `forms-format-list' is specified, Forms mode will supply a
  351. default format list.  This list contains the name of the file being
  352. visited, and a simple label for each field indicating the field number.
  353. File: forms,  Node: Modifying Forms Contents,  Next: Miscellaneous,  Prev: Format Description,  Up: Top
  354. Modifying The Forms Contents
  355. ****************************
  356.    If `forms-read-only' is `nil', the user can modify the fields and
  357. records of the database.
  358.    All normal editing commands are available for editing the contents
  359. of the displayed record.  You cannot delete or modify the fixed,
  360. explanatory text that comes from string formatting elements, but you
  361. can modify the actual field contents.
  362.    If the variable `forms-modified-record-filter' is non-`nil', it is
  363. called as a function before the new data is written to the data file.
  364. The function receives one argument, a vector that contains the contents
  365. of the fields of the record.
  366.    The function can refer to fields with `aref' and modify them with
  367. `aset'.  The first field has number 1 (one); thus, element 0 of the
  368. vector is not used.  The function should return the same vector it was
  369. passed; the (possibly modified) contents of the vector determine what is
  370. actually written in the file.  Here is an example:
  371.      (defun my-modified-record-filter (record)
  372.        ;; Modify second field.
  373.        (aset record 2 (current-time-string))
  374.        ;; Return the field vector.
  375.        record)
  376.      
  377.      (setq forms-modified-record-filter 'my-modified-record-filter)
  378.    If the variable `forms-new-record-filter' is non-`nil', its value is
  379. a function to be called to fill in default values for the fields of a
  380. new record.  The function is passed a vector of empty strings, one for
  381. each field; it should return the same vector, with the desired field
  382. values stored in it.  Fields are numbered starting from 1 (one).
  383. Example:
  384.      (defun my-new-record-filter (fields)
  385.        (aset fields 5 (login-name))
  386.        (aset fields 1 (current-time-string))
  387.        fields)
  388.      
  389.      (setq forms-new-record-filter 'my-new-record-filter)
  390. File: forms,  Node: Miscellaneous,  Next: Error Messages,  Prev: Modifying Forms Contents,  Up: Top
  391. Miscellaneous
  392. *************
  393.    The global variable `forms-version' holds the version information of
  394. the Forms mode software.
  395.    It is very convenient to use symbolic names for the fields in a
  396. record.  The function `forms-enumerate' provides an elegant means to
  397. define a series of variables whose values are consecutive integers.  The
  398. function returns the highest number used, so it can be used to set
  399. `forms-number-of-fields' also.  For example:
  400.      (setq forms-number-of-fields
  401.            (forms-enumerate
  402.             '(field1 field2 field3 ...)))
  403.    This sets `field1' to 1, `field2' to 2, and so on.
  404.    Care has been taken to keep the Forms mode variables buffer-local,
  405. so it is possible to visit multiple files in Forms mode simultaneously,
  406. even if they have different properties.
  407.    If you have visited the control file in normal fashion with
  408. `find-file' or a like command, you can switch to Forms mode with the
  409. command `M-x forms-mode'.  If you put `-*- forms -*-' in the first line
  410. of the control file, then visiting it enables Forms mode automatically.
  411. But this makes it hard to edit the control file itself, so you'd
  412. better think twice before using this.
  413.    The default format for the data file, using `"\t"' to separate
  414. fields and `"\^k"' to separate lines within a field, matches the file
  415. format of some popular database programs, e.g. FileMaker.  So
  416. `forms-mode' can decrease the need to use proprietary software.
  417. File: forms,  Node: Error Messages,  Next: Long Example,  Prev: Miscellaneous,  Up: Top
  418. Error Messages
  419. **************
  420.    This section describes all error messages which can be generated by
  421. forms mode.  Error messages that result from parsing the control file
  422. all start with the text `Forms control file error'.  Messages generated
  423. while analyzing the definition of `forms-format-list' start with `Forms
  424. format error'.
  425. `Forms control file error: 'forms-file' has not been set'
  426.      The variable `forms-file' was not set by the control file.
  427. `Forms control file error: 'forms-number-of-fields' has not been set'
  428.      The variable `forms-number-of-fields' was not set by the control
  429.      file.
  430. `Forms control file error: 'forms-number-of-fields' must be a number > 0'
  431.      The variable `forms-number-of-fields' did not contain a positive
  432.      number.
  433. `Forms control file error: 'forms-field-sep' is not a string'
  434. `Forms control file error: 'forms-multi-line' must be nil or a one-character string'
  435.      The variable `forms-multi-line' was set to something other than
  436.      `nil' or a single-character string.
  437. `Forms control file error: 'forms-multi-line' is equal to 'forms-field-sep''
  438.      The variable `forms-multi-line' may not be equal to
  439.      `forms-field-sep' for this would make it impossible to distinguish
  440.      fields and the lines in the fields.
  441. `Forms control file error: 'forms-new-record-filter' is not a function'
  442. `Forms control file error: 'forms-modified-record-filter' is not a function'
  443.      The variable has been set to something else than a function.
  444. `Forms control file error: 'forms-format-list' is not a list'
  445.      The variable `forms-format-list' was not set to a Lisp list by the
  446.      control file.
  447. `Forms format error: field number XX out of range 1..NN'
  448.      A field number was supplied in `forms-format-list' with a value of
  449.      XX, which was not greater than zero and smaller than or equal to
  450.      the number of fields in the forms, NN.
  451. `Forms format error:  not a function FUN'
  452.      The first element of a list which is an element of
  453.      `forms-format-list' was not a valid Lisp function.
  454. `Forms format error:  invalid element XX'
  455.      A list element was supplied in `forms-format-list' which was not a
  456.      string, number or list.
  457. `Warning: this record has XX fields instead of YY'
  458.      The number of fields in this record in the data file did not match
  459.      `forms-number-of-fields'.  Missing fields will be made empty.
  460. `Multi-line fields in this record - update refused!'
  461.      The current record contains newline characters, hence can not be
  462.      written back to the data file, for it would corrupt it.  Probably
  463.      you inserted a newline in a field, while `forms-multi-line' was
  464.      `nil'.
  465. `Field separator occurs in record - update refused!'
  466.      The current record contains the field separator string inside one
  467.      of the fields. It can not be written back to the data file, for it
  468.      would corrupt it. Probably you inserted the field separator string
  469.      in a field.
  470. `Record number XX out of range 1..YY'
  471.      A jump was made to non-existing record XX.  YY denotes the number
  472.      of records in the file.
  473. `Stuck at record XX'
  474.      An internal error prevented a specific record from being retrieved.
  475. `No write access to `"'FILE`"''
  476.      An attempt was made to enable edit mode on a file that has been
  477.      write protected.
  478. ``"'REGEXP`"' not found'
  479.      The REGEXP could not be found in the data file, starting at the
  480.      current record location.
  481. `Warning: number of records changed to NN'
  482.      Forms mode's idea of the number of records has been adjusted to the
  483.      number of records actually present in the data file.
  484. `Problem saving buffers?'
  485.      An error occurred while saving the data file buffer. Most likely,
  486.      Emacs did ask to confirm deleting the buffer because it had been
  487.      modified, and you said `no'.
  488. File: forms,  Node: Long Example,  Next: Credits,  Prev: Error Messages,  Up: Top
  489. Long Example
  490. ************
  491.    The following example exploits most of the features of Forms mode.
  492. This example is included in the distribution as file `forms-d2.el'.
  493.      ;; demo2 -- demo forms-mode    -*- emacs-lisp -*-
  494.      
  495.      ;; SCCS Status     : demo2    1.1.2
  496.      ;; Author          : Johan Vromans
  497.      ;; Created On      : 1989
  498.      ;; Last Modified By: Johan Vromans
  499.      ;; Last Modified On: Mon Jul  1 13:56:31 1991
  500.      ;; Update Count    : 2
  501.      ;; Status          : OK
  502.      ;;
  503.      ;; This sample forms exploit most of the features of forms mode.
  504.      
  505.      ;; Set the name of the data file.
  506.      (setq forms-file "forms-d2.dat")
  507.      
  508.      ;; Use `forms-enumerate' to set field names and number thereof.
  509.      (setq forms-number-of-fields
  510.            (forms-enumerate
  511.             '(arch-newsgroup            ; 1
  512.           arch-volume            ; 2
  513.           arch-issue            ; and ...
  514.           arch-article            ; ... so
  515.           arch-shortname            ; ... ... on
  516.           arch-parts
  517.           arch-from
  518.           arch-longname
  519.           arch-keywords
  520.           arch-date
  521.           arch-remarks)))
  522.      
  523.      ;; The following functions are used by this form for layout purposes.
  524.      ;;
  525.      (defun arch-tocol (target &optional fill)
  526.        "Produces a string to skip to column TARGET.
  527.      Prepends newline if needed.
  528.      The optional FILL should be a character, used to fill to the column."
  529.        (if (null fill)
  530.            (setq fill ? ))
  531.        (if (< target (current-column))
  532.            (concat "\n" (make-string target fill))
  533.          (make-string (- target (current-column)) fill)))
  534.      ;;
  535.      (defun arch-rj (target field &optional fill)
  536.        "Produces a string to skip to column TARGET\
  537.       minus the width of field FIELD.
  538.      Prepends newline if needed.
  539.      The optional FILL should be a character,
  540.      used to fill to the column."
  541.        (arch-tocol (- target (length (nth field forms-fields))) fill))
  542.      
  543.      ;; Record filters.
  544.      ;;
  545.      (defun new-record-filter (the-record)
  546.        "Form a new record with some defaults."
  547.        (aset the-record arch-from (user-full-name))
  548.        (aset the-record arch-date (current-time-string))
  549.        the-record)                ; return it
  550.      (setq forms-new-record-filter 'new-record-filter)
  551.      
  552.      ;; The format list.
  553.      (setq forms-format-list
  554.           (list
  555.             "====== Public Domain Software Archive ======\n\n"
  556.             arch-shortname
  557.             " - "            arch-longname
  558.             "\n\n"
  559.             "Article: "        arch-newsgroup
  560.             "/"            arch-article
  561.             " "
  562.             '(arch-tocol 40)
  563.             "Issue: "        arch-issue
  564.             " "
  565.             '(arch-rj 73 10)
  566.             "Date: "            arch-date
  567.             "\n\n"
  568.             "Submitted by: "        arch-from
  569.             "\n"
  570.             '(arch-tocol 79 ?-)
  571.             "\n"
  572.             "Keywords: "        arch-keywords
  573.             "\n\n"
  574.             "Parts: "        arch-parts
  575.             "\n\n====== Remarks ======\n\n"
  576.             arch-remarks
  577.           ))
  578.      
  579.      ;; That's all, folks!
  580. File: forms,  Node: Credits,  Next: Index,  Prev: Long Example,  Up: Top
  581. Credits
  582. *******
  583.    Bug fixes and other useful suggestions were supplied by Harald
  584. Hanche-Olsen (`hanche@imf.unit.no'), `cwitty@portia.stanford.edu',
  585. Jonathan I. Kamens, Per Cederqvist  (`ceder@signum.se'), Michael Lipka
  586. (`lipka@lip.hanse.de'), Andy Piper (`ajp@eng.cam.ac.uk'), Frederic
  587. Pierresteguy  (`F.Pierresteguy@frcl.bull.fr'), Ignatios Souvatzis and
  588. Richard Stallman (`rms@gnu.ai.mit.edu').
  589.    This documentation was slightly inspired by the documentation of
  590. "rolo mode" by Paul Davis at Schlumberger Cambridge Research
  591. (`davis%scrsu1%sdr.slb.com@relay.cs.net').
  592.    None of this would have been possible without GNU Emacs of the Free
  593. Software Foundation.  Thanks, Richard!
  594. File: forms,  Node: Index,  Prev: Credits,  Up: Top
  595. Index
  596. *****
  597. * Menu:
  598. * TAB:                                  Forms Commands.
  599. * begin:                                Forms Commands.
  600. * C-c <:                                Forms Commands.
  601. * C-c >:                                Forms Commands.
  602. * C-c TAB:                              Forms Commands.
  603. * C-c C-k:                              Forms Commands.
  604. * C-c C-l:                              Forms Commands.
  605. * C-c C-n:                              Forms Commands.
  606. * C-c C-o:                              Forms Commands.
  607. * C-c C-p:                              Forms Commands.
  608. * C-c C-q:                              Forms Commands.
  609. * C-c C-r REGEXP RET:                   Forms Commands.
  610. * C-c C-s REGEXP RET:                   Forms Commands.
  611. * C-x C-s:                              Forms Commands.
  612. * control file:                         Control File Format.
  613. * end:                                  Forms Commands.
  614. * field:                                Data File Format.
  615. * forms-check-number-of-fields:         Control File Format.
  616. * forms-delete-record:                  Forms Commands.
  617. * forms-enumerate:                      Miscellaneous.
  618. * forms-field-sep <1>:                  Control File Format.
  619. * forms-field-sep:                      Data File Format.
  620. * forms-fields:                         Format Description.
  621. * forms-file:                           Control File Format.
  622. * forms-find-file:                      Entering and Exiting Forms Mode.
  623. * forms-find-file-other-window:         Entering and Exiting Forms Mode.
  624. * forms-first-record:                   Forms Commands.
  625. * forms-format-list <1>:                Control File Format.
  626. * forms-format-list:                    Format Description.
  627. * forms-insert-after:                   Control File Format.
  628. * forms-insert-record:                  Forms Commands.
  629. * forms-jump-record:                    Forms Commands.
  630. * forms-last-record:                    Forms Commands.
  631. * forms-mode:                           Miscellaneous.
  632. * forms-mode-hooks:                     Entering and Exiting Forms Mode.
  633. * forms-modified-record-filter:         Control File Format.
  634. * forms-multi-line <1>:                 Data File Format.
  635. * forms-multi-line:                     Control File Format.
  636. * forms-new-record-filter:              Control File Format.
  637. * forms-next-field:                     Forms Commands.
  638. * forms-next-record:                    Forms Commands.
  639. * forms-number-of-fields:               Control File Format.
  640. * forms-prev-field:                     Forms Commands.
  641. * forms-prev-record:                    Forms Commands.
  642. * forms-print:                          Forms Commands.
  643. * forms-read-file-filter <1>:           Control File Format.
  644. * forms-read-file-filter:               Data File Format.
  645. * forms-read-only:                      Control File Format.
  646. * forms-save-buffer:                    Forms Commands.
  647. * forms-search-backward:                Forms Commands.
  648. * forms-search-forward:                 Forms Commands.
  649. * forms-toggle-read-only:               Forms Commands.
  650. * forms-version:                        Miscellaneous.
  651. * forms-write-file-filter <1>:          Control File Format.
  652. * forms-write-file-filter:              Data File Format.
  653. * next:                                 Forms Commands.
  654. * prior:                                Forms Commands.
  655. * pseudo-newline:                       Data File Format.
  656. * record:                               Data File Format.
  657. * S-Tab:                                Forms Commands.
  658. Tag Table:
  659. Node: Top
  660. Node: Forms Example
  661. Node: Entering and Exiting Forms Mode
  662. Node: Forms Commands
  663. Node: Data File Format
  664. Node: Control File Format
  665. 10287
  666. Node: Format Description
  667. 14305
  668. Node: Modifying Forms Contents
  669. 17647
  670. Node: Miscellaneous
  671. 19534
  672. Node: Error Messages
  673. 21072
  674. Node: Long Example
  675. 24960
  676. Node: Credits
  677. 28032
  678. Node: Index
  679. 28792
  680. End Tag Table
  681.